<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>Promise</title>
</head>

<body>

	<p>Promise使用2</p>
	<p id="demo"></p>
	<script>

		function step1() {
			return new Promise(resolve => {
				setTimeout(() => resolve("步骤1完成"), 1000);
			});
		}

		function step2(prevResult) {
			return new Promise(resolve => {
				setTimeout(() => resolve(prevResult + " → 步骤2完成"), 1000);
			});
		}

		function step3(prevResult) {
			return new Promise(resolve => {
				setTimeout(() => resolve(prevResult + " → 步骤3完成"), 1000);
			});
		}

		step1()
			.then(result1 => step2(result1))
			.then(result2 => step3(result2))
			.then(finalResult => {
				console.log("最终结果:", finalResult);
			})
			.catch(error => {
				console.error("出错了:", error);
			});


	</script>

</body>

</html>